package com.banyuan;

import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;

import java.io.*;

public class BufferWriteTest {
    public static void main(String[] args) {
        OutputStream os = null;
        OutputStreamWriter osw = null;
        BufferedWriter bw = null;

        try {
            try {
                os = new FileOutputStream("/Users/edy/Desktop/file/1.txt",true);
                osw = new OutputStreamWriter(os,"UTF-8");
                bw = new BufferedWriter(osw);

                bw.write("我是中国人，asdasdasdasdasdasdasdasdasdsadasdasdasd");
                bw.newLine(); // 换行
                bw.flush(); //一次性写入
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } finally {
          IOUtilis.closeQuiety(bw);
          IOUtilis.closeQuiety(osw);
          IOUtilis.closeQuiety(os);
        }
    }
}
